function fval = objfun(theta,N,T,lambda1,lambda2,q_team,q_sp,nScore,Svalues,mergers_data,subs_data,nSim)               

sigmaS=exp(theta(1));
sigmaT=exp(theta(2));

[mergers, subs, ~, ~]=equilibrium(sigmaS,sigmaT,N,T,lambda1,lambda2,q_team,q_sp,nScore,Svalues,mergers_data,nSim);

fval = ((mergers-mergers_data)/mergers_data)^2 + ((subs-subs_data)/subs_data)^2;

end